/*************************************************
filename	: keyframed_entity.h
author		: Stefan lulham
desc		: Contains the base for the animated entity class. An animated entity is made
				up of one, or many, entity poses. They also contain a list of animations similar
				to sprites, when being drawn a tempory mesh is created by taking the current
				animation frame pose and the next frame as well and then vertex position are
				calculated by linearly interpolating between the two.
*************************************************/
#ifndef D_ANIMATED_ENTITY_H
#define D_ANIMATED_ENTITY_H

#include <iostream>
#include <vector>
#include <map>
#include <modules\graphics\entity_pose.h>
#include <modules\graphics\model.h>
#include <modules\graphics\animatable.h>
#include <modules\graphics\animation.h>
#include <modules\graphics\entity.h>

using namespace std;

namespace DelGE
{
	namespace Modules
	{
		namespace Graphics
		{
			class AnimatedEntity : public Entity, public Animatable
			{
			private:
				AnimatedEntity(AnimatedEntity *pEntity);

				vector<Model*> vRenderModels;
				vector<EntityPose*> vPoses;

				void UpdateRenderModels(EntityPose* pPose0, EntityPose* pPose1, float fInterpoleValue = 0.0f);
				void UpdateRenderModel(int iModelIndex, EntityPose* pPose0, EntityPose* pPose1, float fInterpoleValue = 0.0f);
				void BuildRenderModels();

				void DestroyPoses();
				void DestroyRenderModels();

			public:
				AnimatedEntity();
				~AnimatedEntity();

				static AnimatedEntity* ShallowCopy(AnimatedEntity *pEntity);

				void AddPose(EntityPose *pPose = NULL);
				EntityPose *GetPose(int iIndex = -1);
				int GetPoseCount();

				void UpdateAnimation(float fDelta);

				void AddModel(Model* pModel = NULL);
				Model* GetModel(int iIndex);
				int GetModelCount();

				Model* GetRenderModel(int iModelIndex);

				void Destroy();
			};
		}
	}
}

#endif